using System;
using System.Diagnostics;

namespace Pegasus.ServiceProcess
{
	/// <summary>
	/// Listener for the service applciation form.  This class routes all message from the lister to 
	/// the text box on the form.
	/// </summary>
	internal class ServiceApplicationListener : TraceListener
	{
		// Local Instance Values
		private FormServiceApplication m_appForm;

		/// <summary>
		/// Initializes a new instance of the <see cref="T:ListenerServiceApplication"/> class.
		/// </summary>
		/// <param name="appForm">The app form.</param>
		public ServiceApplicationListener( FormServiceApplication appForm )
		{
			m_appForm = appForm;
		}

		/// <summary>
		/// When overridden in a derived class, writes the specified message to the listener you create in the derived class.
		/// </summary>
		/// <param name="message">A message to write.</param>
		public override void Write( string message )
		{
			m_appForm.WriteText( message );
		}

		/// <summary>
		/// When overridden in a derived class, writes a message to the listener you create in the derived class, followed by a line terminator.
		/// </summary>
		/// <param name="message">A message to write.</param>
		public override void WriteLine( string message )
		{
			m_appForm.WriteText( message + '\n' );
		}
	}
}